from Goldenberry.optimization.ga.GbMutatorMgr.BinaryMutators import *
from Goldenberry.optimization.ga.GbMutatorMgr.RealMutators import *
from Goldenberry.optimization.base.GbSolution import GbIndividual
from Goldenberry.optimization.ga.GbMutatorMgr.MutatorContext import MutatorContext
#from Goldenberry.optimization.ga.DataType.MutationParams import MutationParams
from Goldenberry.optimization.ga.GbMutatorMgr.IMutatorMgt import IMutatorMgt
from Goldenberry.optimization.ga.GbMutatorMgr.IMutatorSetup import IMutatorSetup

class Mutator(IMutatorMgt, IMutatorSetup):
    """description of class"""
    def __init__(self):
        self.mutator_context = MutatorContext()

    #Override methods of IMutatorMgt
    def set_mutation(self, mutation_method):
        if mutation_method == 'OneBitBinaryMutation':
           self.mutator_context.set_curr_mutation_str(OneBitBinaryMutation())
        elif mutation_method == 'MultipleBitBinaryMutation':
           self.mutator_context.set_curr_mutation_str(MultipleBitBinaryMutation())
        else:
           self.mutator_context.set_curr_mutation_str(TruncateGaussMutation())

    def mutate(self, individual, prob):
        return self.mutator_context.mutate(individual, prob)

    #Override methods of IMutatorSetup
    def get_mutation_method(self):
        return self.mutation_method

    def set_mutation_method(self, mutation_method):
        self.mutation_method = mutation_method #MutationParams(mutation_method)
        



